<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>调查主题</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/style.css" />
<script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/jquery.artDialog.js?skin=default" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/plugins/iframeTools.js" type="text/javascript"></script>
<script src="__PUBLIC__/DatePicker/WdatePicker.js" type="text/javascript"></script>
</head>
<body>
<div id="main">
    <form id="login-form" action="__URL__/edit" method="post">
        <input type="hidden" value="post" name="action" />
        <input type="hidden" value="{$info['id']}" name="fid" />
        <table width="100%" class="table_form">
            <tr><th width="120">调查主题</th><td><input id="title" type="text" name="title" class="input-text" size="50" value="{$info['title']}" /><span class="hot">*</span></td></tr>
            <tr><th>赠送积分</th><td><input id="vip" type="text" name="vip" class="input-text" size="10" value="{$info['vip']}" /><span class="hot">*</span>参加调查赠送积分，只能填整数</td></tr>
            <tr><th>调查时间</th><td><input id="starttime" onClick="WdatePicker()" type="text" name="starttime" class="input-text input-date" size="20" value="{if $info['starttime']}{date('Y-m-d',$info['starttime'])}{/if}" readonly="readonly" />< = ><input id="endtime" onClick="WdatePicker()" type="text" name="endtime" class="input-text input-date" size="20" value="{if $info['endtime']}{date('Y-m-d',$info['endtime'])}{/if}" readonly="readonly" /><span class="hot">*</span></td></tr>
            <tr><th>调查备注</th><td><textarea  id="about" name="about" style="height: 70px; width: 340px">{$info['about']}</textarea><span class="hot">*</span></td></tr>
            <tr><th>标题关键词(30):</th><td><input id="titlekey" type="text" name="titlekey" class=":required :max_length;30 input-text" size="60" value="{$info['titlekey']}" /><span class="hot">*</span></td></tr>
            <tr><th>页面关键词(60):</th><td><textarea id="keywords" class=":required :max_length;80 input-text" name="keywords" style="height: 50px; width: 340px">{$info['keywords']}</textarea><span class="hot">*</span></td></tr>
            <tr><th>页面描述(120):</th><td><textarea  id="description" class=":required :max_length;120 input-text" name="description" style="height: 60px; width: 340px">{$info['description']}</textarea><span class="hot">*</span></td></tr>          
        </table>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        var parent = art.dialog.parent,	// 父页面window对象
        api = art.dialog.open.api,//art.dialog.open扩展方法
        $ = function (id) {return document.getElementById(id)},
        form        = $('login-form'),
        title       = $('title'),
        vip         = $('vip'),
        starttime   = $('starttime'),
        endtime     = $('endtime'),
        about       = $('about'),
        titlekey    = $('titlekey'),
        keywords    = $('keywords'),
        description = $('description');
        if (!api) return;
        api.title('添加/编辑')// 操作对话框
        .button({ // 自定义按钮
            name: '提交',
            callback: function () {
                if (check(title)&&check(vip)&&isnum(vip)&&check(starttime)&&check(endtime)&&check(about)&&check(titlekey)&&check(keywords)&&check(description)) form.submit();
                return false;
            },focus: true
        },{name: '取消'});
        // 表单验证
        var check = function (input) {
            if (input.value === '') {
                inputError(input);
                input.focus();
                return false;
            } else {
                return true;
            };
        };
        // 是否数字
        var isnum = function (input) {
            var strP=/^\d+$/;
            if(!strP.test(input.value)){
                inputError(input);
                input.focus();
                return false;
            }else {
                return true;
            };
        };
        // 输入错误提示
        var inputError = function (input){
            clearTimeout(inputError.timer);
            var num = 0;
            var fn = function () {
                inputError.timer = setTimeout(function () {
                    input.className = input.className === '' ? 'login-form-error' : '';
                    if (num === 5) {
                        input.className === '';
                    } else {
                        fn(num ++);
                    };
                }, 150);
            };
            fn();
        };
        window.onload = function () {setTimeout(function () {username.focus()}, 240);};
    })();
</script>